<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace app\api\validate;
use think\Request;
use think\Validate;
use think\Exception;
use app\lib\exception\ParameterException;
/**
 * Description of BaseValidate
 *
 * @author Administrator
 */
class BaseValidate extends Validate 
{
    public function  goCheck()
    {
        //获取http传入的参数
        //对这些参数做校验
        $request = Request::instance();
        $params = $request->param();
       
        $request = $this->check($params);
        if(!$request){
            $e = new ParameterException([
                'msg'=> $this->error,
            ]);
            throw  $e;
        }
        else{
            return true;
        }
    }
    
    protected function isPositiveInteger($value,$rule='',$date='',$field='')
    {    
      
        if(is_numeric($value) && is_int($value+0) && ($value +0)>0){
        
            return true;
        }
        else{
              return false;
        }
      
    }
}
